<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Xppass Administrator's Control Panel</title>
<LINK href="<?php echo $www_site_url?>/public/yav-style.css" type=text/css rel=stylesheet>
<script src="<?php echo $www_site_url?>/public/js/common.js" type="text/javascript"></script>
<script src="<?php echo $www_site_url?>/public/js/ajax.js" type="text/javascript"></script>
</head>

<script type="text/javascript">
function viewUser(user_id){
	var url = "<?php echo $www_site_url?>/admin.php?action=user&view=detail&detail=contact&user_id="+user_id;
	window.location = url;
}

function viewAssignHistory(user_id, user_name){
	var url = "<?php echo $www_site_url?>/admin.php?action=assignment&view=gethistory&user_id="+user_id+"&user_name="+user_name;
	window.location = url;
}

function toExcel(a_id,b_id,a_title){
	//alert(a_id+"  "+b_id+"  "+a_title);
	var url = "<?php echo $www_site_url?>/admin.php?action=assignment&view=apptoexcel&a_id="+a_id+"&b_id="+b_id+"&a_title="+a_title;
	//alert(url);
	window.location = url;

/*
	var shtml = document.getElementById('applicant_list').innerHTML;
	var a_title = document.getElementById('a_title').innerHTML;

	var startid = shtml.indexOf('<!--excelstart-->');

	var html = shtml.substr(startid+17);
	var endid = html.indexOf('<!--excelend-->');

	var xlshtml = html.substr(0,endid);

	var aa = xlshtml.toLowerCase();

	//以下这些过滤暂时只对FF浏览器有作用，在IE和Chrome浏览器中，提交按钮及单选钮仍然过滤不掉。对正则表达式还要再熟悉
	//滤去昵称上的超链接
	aa = aa.replace(/<a href=\"javascript:viewUser\(\'[0-9]+\'\)\">/gi, "");

	//滤去提交按钮
	//aa = aa.replace(/<input (value=[\"]*提交[\"]*) (class=[\"]*button[\"]*) (type=[\"]*submit[\"]*)>/g, "");
	aa = aa.replace(/<input.*(submit)[^>]*>/gi, "");

	//滤去昵称的加粗显示
	aa = aa.replace(/<strong>/g, "");

	//滤去单选钮
	//aa = aa.replace(/<input name=\"s\" value=\"[0-9]+\" [ a-z=\"]*type=\"radio\">/g, "");
	aa = aa.replace(/<input.*(radio)[^>]*>/gi,"");

	//滤去导出excel按钮
	aa = aa.replace(/<input.*(导出为excel)[^>]*>/gi,"");

	//滤去“选择列”
	aa = aa.replace(/<th>选择<\/th>/g, "");



	//生成excel
	var url = "<?php echo $www_site_url?>/plugins/exceltmp.php";

	mini.ajax.post(url, function(r){
	window.location.href = "<?php echo $www_site_url?>/plugins/excel.php";
	}, "html="+encodeURIComponent(aa)+"&title="+a_title);

//	alert(aa);
*/
	return false;
}
</script>

<body><div id="append"></div>
<div id="msg" style="color:red;text-align:center"></div>


	<div class="container">

		<h3>选择申请人</h3>
		<h3 id="a_title"><?php echo lang('a_title')?>:<?php echo $a_title;?></h3>

		<div class="mainbox" id="applicant_list">
				<form action="<?php echo $www_site_url?>/admin.php" method="post">
				<input type="hidden" name="action" value="assignment">
				<input type="hidden" name="op" value="choose">
				<input type="hidden" name="a_id" value="<?php echo $a_id?>">
				<!--excelstart-->
				<table class="datalist fixwidth">
					<tr>
						<th>ID</th>
						<th><?php echo lang('realname')?></th>
						<th><?php echo lang('nickname')?></th>
						<th><?php echo lang('completedassign')?></th>
						<th><?php echo lang('totalcompleted')?></th>
						<th><?php echo lang('gender')?></th>
						<th><?php echo lang('mobile')?></th>
						<th><?php echo lang('occupation')?></th>
						<th><?php echo lang('holdincome')?></th>
						<th><?php echo lang('birthdate')?></th>
						<th><?php echo lang('selected')?></th>
					</tr>
						<?php if(isset($applicant) && is_array($applicant)){
							foreach ($applicant as $v){?>
						<tr>
							<td><?php echo $v['user_id']?></td>
							<td><?php echo $v['realname']?></td>
							<td><a href="javascript:viewUser('<?php echo $v['user_id']?>')"><strong><?php echo $v['nickname']?></strong></a></td>
							<td><?php echo $v['completedassign']?></td>
							<td><a href="javascript:viewAssignHistory('<?php echo $v['user_id']?>', '<?php echo $v['realname']?>')" title="view assignment history"><?php echo $v['totalcompleted']?></a></td>
							<td><?php if($v['gender']==1)echo "先生";if($v['gender']==2)echo "女士";?></td>
							<td><?php echo $v['mobile']?></td>
							<td><?php echo $v['occupation']?></td>
							<td><?php if($v['income']==1) echo lang('holdincome1');
										elseif($v['income']==2) echo lang('holdincome2');
										elseif($v['income']==3) echo lang('holdincome3');
										elseif($v['income']==4) echo lang('holdincome4');
										elseif($v['income']==5) echo lang('holdincome5');
										elseif($v['income']==6) echo lang('holdincome6');
										elseif($v['income']==7) echo lang('holdincome7');?></td>
							<td><?php echo $v['birthdate']?></td>

							<td><input type="radio" name="s" value="<?php echo $v['user_id']?>" <?php if($v['selected']==1) echo "checked";?>></td>

						</tr>

						<?php }
						}?>
										<tr class="nobg">
						<td><input type="submit" value="<?php echo lang('submit')?>" class="button" /></td>
						<td class="tdpage" colspan="8" align="right"><input type="button" class="button" value="导出为excel" onclick="return toExcel(<?php echo $a_id?>,<?php echo $b_id?>,'<?php echo $a_title?>');" /></td>
					</tr>
				</table>
				<!--excelend-->

				</form>
					</div>

	</div>

</body>
</html>